#include <bits/stdc++.h>
using namespace std;

#define int long long

int n, m, k, g[100001], dist1[100001], dist2[100001];

vector<pair<int, int>> edges[100001], edges2[100001];

void dijistra(int st, int* ds)
{
    queue<int> q;
    memset(ds, 0x3f, sizeof dist1);
    ds[st] = 0;
    q.push(st);
    while (!q.empty()) {
        int x = q.front();
        q.pop();
        for (auto t : edges[x]) {
            if (ds[t.second] > ds[x] + t.first)
                ds[t.second] = ds[x] + t.first, q.push(t.second);
        }
    }
    return;
}

void dijistra2(int st, int* ds)
{
    queue<int> q;
    memset(ds, 0x3f, sizeof dist2);
    ds[st] = 0;
    q.push(st);
    while (!q.empty()) {
        int x = q.front();
        q.pop();
        for (auto t : edges2[x]) {
            if (ds[t.second] > ds[x] + t.first)
                ds[t.second] = ds[x] + t.first, q.push(t.second);
        }
    }
    return;
}

signed main()
{
    cin.tie(0), cout.tie(0);
    cin >> n >> m >> k;
    for (int i = 1; i <= m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        edges[a].push_back(make_pair(c, b));
        edges[b].push_back(make_pair(c, a));
        edges2[a].push_back(make_pair(c, b));
        edges2[b].push_back(make_pair(c, a));
        edges2[a + n].push_back(make_pair(c, b + n));
        edges2[b + n].push_back(make_pair(c, a + n));
    }
    for (int i = 1; i <= k; i++) {
        int a, b;
        cin >> a >> b;
        g[a] = max(g[a], b);
        for (auto x : edges[a])
            edges2[x.second + n].push_back(make_pair(x.first - g[a], a));
    }
    dijistra(n, dist1);
    dijistra2(n + n, dist2);
    for (int i = 1; i < n; i++) {
        if (dist2[i] <= dist1[i])
            cout << 1 << endl;
        else
            cout << 0 << endl;
    }
    return 0;
}